package main

import (
	"yuanchang/betlog/http"
	"time"
)

func main() {
	exit := make(chan bool)
	ticker := time.Tick(time.Second)
	go func() {
		for {
			<-ticker
			betLog()
		}
	}()
	for {
		<-exit
	}
}

func betLog() {
	r, _ := http.NewRequest("POST", "http://operatorapi.staging.imaegisapi.com/Report/GetBetLog")
	body := createRequestBody()
	r.SetBody("json", body)
	response, _ := r.Do()
	content, _ := response.GetContent()
	println(string(content))
}

func createRequestBody() map[string]string {
	body := make(map[string]string)
	now := time.Now()
	tm := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
	startDate := tm.Format("2006-01-02 15.04.05")
	endDate := tm.Add(time.Hour * 24).Format("2006-01-02 15.04.05")
	println(endDate, startDate)
	body["MerchantCode"] = "OJCAtD9S6Yq32vIRN7KOkCAE7BxQxxRa"
	body["StartDate"] = startDate
	body["EndDate"] = endDate
	body["Page"] = "1"
	body["ProductWallet"] = "401"
	body["DateFilterType"] = "1"
	//body["LastUpdatedDate"] = ""
	body["Language"] = "ZH-CN"
	return body
}
